﻿using System;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x020003B8 RID: 952
[RequireComponent(typeof(Toggle))]
public class PresetListToggle : MonoBehaviour
{
	// Token: 0x17000250 RID: 592
	// (get) Token: 0x060017B7 RID: 6071 RVA: 0x0009C7B8 File Offset: 0x0009A9B8
	public Toggle toggle
	{
		get
		{
			if (this._toggle == null)
			{
				this._toggle = base.GetComponent<Toggle>();
			}
			return this._toggle;
		}
	}

	// Token: 0x17000251 RID: 593
	// (get) Token: 0x060017B8 RID: 6072 RVA: 0x0009C7E0 File Offset: 0x0009A9E0
	// (set) Token: 0x060017B9 RID: 6073 RVA: 0x0009C7F0 File Offset: 0x0009A9F0
	public bool interactable
	{
		get
		{
			return this.toggle.interactable;
		}
		set
		{
			this.toggle.interactable = value;
		}
	}

	// Token: 0x060017BA RID: 6074 RVA: 0x0009C800 File Offset: 0x0009AA00
	public void Setup(MoveableThumbnailSelectUI selectUI)
	{
		this.selectUI = selectUI;
	}

	// Token: 0x060017BB RID: 6075 RVA: 0x0009C80C File Offset: 0x0009AA0C
	public void ToggleSelectUI(bool flag)
	{
		if (!this.invoke)
		{
			return;
		}
		if (this.selectUI != null)
		{
			if (flag)
			{
				this.selectUI.Open(this._toggle);
			}
			else if (this.selectUI.openUI == this._toggle)
			{
				this.selectUI.Close();
			}
		}
	}

	// Token: 0x060017BC RID: 6076 RVA: 0x0009C878 File Offset: 0x0009AA78
	public void OnChangeState(MoveableUI.STATE state)
	{
		this.invoke = false;
		this.toggle.isOn = (state != MoveableUI.STATE.CLOSED);
		this.invoke = true;
	}

	// Token: 0x060017BD RID: 6077 RVA: 0x0009C89C File Offset: 0x0009AA9C
	private void OnDisable()
	{
		if (this.selectUI != null && this.selectUI.openUI == this._toggle)
		{
			this.selectUI.Close();
		}
		this.toggle.isOn = false;
	}

	// Token: 0x060017BE RID: 6078 RVA: 0x0009C8EC File Offset: 0x0009AAEC
	private void Update()
	{
		if (this.toggle.isOn && this.selectUI.openUI != this._toggle)
		{
			this.invoke = false;
			this.toggle.isOn = false;
			this.invoke = true;
		}
	}

	// Token: 0x04001B3F RID: 6975
	[SerializeField]
	private MoveableThumbnailSelectUI selectUI;

	// Token: 0x04001B40 RID: 6976
	private bool invoke = true;

	// Token: 0x04001B41 RID: 6977
	public Action onDisable;

	// Token: 0x04001B42 RID: 6978
	private Toggle _toggle;
}
